import urllib.request
import urllib.parse
import re

f = urllib.request.urlopen(
    "http://127.0.0.1:32767/20.06.58/%E4%B8%BB%E7%95%8C%E9%9D%A2.html")  # 抓取访问url的响应报文
htmlText = f.read()
imglist = re.findall(r'src="(.*?\.(jpg|png))"',
                     htmlText.decode('UTF-8'))  # 获取所有的图片url
x = 0
urlHead = 'http://127.0.0.1:32767/20.06.58/'
for imgurl in imglist:
    print(urlHead + imgurl[0])
    urllib.request.urlretrieve(
        urlHead + urllib.parse.quote(imgurl[0]), './downloads/%d.png' % x)  # 保存所有图片
    x += 1
